home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / auxlib / get_available_aux_window.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-18  |  1.8 KB  |  75 lines

  1. /*
  2. ### get available combined space windows ###
  3.  
  4. Return: 0: do not recreate window (use existing one)
  5.     1: create a new window with this index
  6.     2: destroy window with this index and recreate it
  7. Output: *t_aux_win_i: index of the auxiliary window
  8. Indirect Output: if auto_option>0, aux_win_mode[*t_aux_win_i] is set to 1
  9.         otherwise, 0.
  10. */
  11.  
  12. int get_available_aux_window(t_aux_win_i)
  13. int *t_aux_win_i;
  14. {
  15.     int i,result;
  16.     extern int aux_max;
  17.     extern int *aux_on,*aux_win_mode;
  18.     extern int auto_option;
  19.     extern char auto_file_name[],error_mess[],error_yes[],error_no[];
  20.     /* t_aux_win_i runs from 0 to aux_max-1 */
  21.     /* Count the number of open auxiliary windows */
  22.     for(i=0;i<aux_max;i++){
  23.         if(!aux_on[i]){
  24.             *t_aux_win_i = i;
  25.             if(auto_option>0)
  26.                 aux_win_mode[i]=1;
  27.             else
  28.                 aux_win_mode[i]=0;
  29.             return(1);
  30.         }
  31.     }
  32.     /* All the auxiliary windows are used up. Take over one. */
  33.     for(i=0;i<aux_max;i++){
  34.         if(i==0){
  35.             sprintf(error_mess,"No more aux windows. RECREATE an existing aux_win[%d]?",i);
  36.             sprintf(error_yes,"Confirm");
  37.             if(i != aux_max-1){
  38.                 sprintf(error_no,"No. Move to next aux_win[%d]",i+1);
  39.             }
  40.             else {
  41.                 sprintf(error_no,"No, use current winsow as it is");
  42.             }
  43.         }
  44.         else if(i<aux_max-1){
  45.             sprintf(error_mess,"How about this aux_win[%d]?",i);
  46.             sprintf(error_yes,"Confirm");
  47.             sprintf(error_no,"Nope. Next!");
  48.         }
  49.         else {
  50.             sprintf(error_mess,"This is the last chance. Do you want get aux_win[i]?",i);
  51.             sprintf(error_yes,"Confirm");
  52.             sprintf(error_no,"Cancel. Exit!");
  53.         }
  54.         result = (int) error_mess_proc(error_mess,error_yes,error_no);
  55.         if(result){
  56.             *t_aux_win_i = i;
  57.             if(auto_option>0)
  58.                 aux_win_mode[i]=1;
  59.             else
  60.                 aux_win_mode[i]=0;
  61.             return(2);
  62.         }
  63.         else {
  64.             if(i==0){
  65.                 *t_aux_win_i = i;
  66.                 if(auto_option>0)
  67.                     aux_win_mode[i]=1;
  68.                 else
  69.                     aux_win_mode[i]=0;
  70.                 return(0);
  71.             }
  72.         }
  73.     }
  74. }
  75.